package com.emagic.manage.modules.room.adapter;

import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.emagic.manage.R;
import com.emagic.manage.modules.room.view.RoomFile;

import java.util.List;

/**
 * Created by xiatian on 2017/12/12.
 */

public class VideoAdapter extends BaseQuickAdapter<RoomFile, BaseViewHolder> {
    public VideoAdapter(List<RoomFile> data) {
        super(R.layout.view_file_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RoomFile item) {
        helper.setText(R.id.file_name, item.getFilename());
        ImageView typeImg = helper.getView(R.id.type_img);
        TextView fileName = helper.getView(R.id.file_name);

        if (item.getFiletype().equals("mp4") || item.getFiletype().equals("webm")) {
            typeImg.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_mp4_type));
        } else if (item.getFiletype().equals("mp3") || item.getFiletype().equals("wav") || item.getFiletype().equals("ogg")) {
            typeImg.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_mp3_type));
        }
        if ("0".equals(item.getState())) {
            fileName.setTextColor(mContext.getResources().getColor(R.color.white));
        } else if ("1".equals(item.getState())) {
            fileName.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
        }
    }
}
